package com.inepex.inechart.client.displayengine;

import com.google.gwt.user.client.ui.IsWidget;

public abstract class RectangleTile implements IsWidget, Comparable<RectangleTile>{
	
	protected int column;
	protected int row;
	protected int width, height;
	
	protected RectangleTile(){
		
	}
	
	protected RectangleTile(int row, int column, int width, int height){
		this.row = row;
		this.column = column;
		this.height = height;
		this.width = width;
	}
	
	public int getColumn(){
		return column;
	}
	
	public int getRow(){
		return row;
	}
		
	@Override
	public int compareTo(RectangleTile o) {
		int comp = ((Integer)row).compareTo(o.row);
		if(comp == 0){
			comp =  ((Integer)column).compareTo(o.column);
		}
		return comp;
	}
	
	public int getTop(){
		return row * height;
	}
	
	public int getLeft(){
		return column * width;
	}
	
	public int getRight(){
		return (row + 1) * height;
	}
	
	public int getBottom(){
		return (column + 1) * width;
	}

	public int getWidth() {
		return width;
	}

	public int getHeight() {
		return height;
	}

	public void setColumn(int column) {
		this.column = column;
	}

	public void setRow(int row) {
		this.row = row;
	}
	
	public void setSize(int width, int height){
		this.width = width;
		this.height = height;				
	}
}
